home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
SREFPRC1.ZIP
/
FIX_URL.SRF
< prev
next >
Wrap
Text File
|
1996-05-13
|
2KB
|
76 lines
/* ----------------------------------------------------------------------- */
/* FIX_URL: Make a fully specified http://url out of message */
/* mayl not work if subdirectories have periods */
/* ----------------------------------------------------------------------- */
sref_fix_url:
parse arg message,servername,serverport
/* use defaults if not provided */
if servername="" then
servername=servername()
if serverport="" then
serverport=extract(serverport)
message=strip(translate(message,'/','\'))
if abbrev(translate(message),"HTTP://")=1 then
return message /* assume the rest is legit */
/* if not a fully qualified http url (i.e. http://xxx.yyy/zzz) then
make it so
Rule: (assuming no http:// in message)
Strip leading any leading /
Look for a / If no slash found,
look for periods. If > 1 found, it's a "default" for a ip address
if <2 found, it's a local file
Check stuff before first /.
If it has any periods, its an ip address (stuff after is the url)
If no periods, it's a local url (stuff before is first subdirectory)
*/
message=strip(message,'l','/')
islash=pos('/',message)
if islash=0 then do
foo=translate(message,' ','.')
if words(foo)>2 then do
anip=message
aport=80
afile=""
end
else do
anip=servername
aport=serverport
afile=message
end
end /* no slashes found */
else do
parse var message p1 '/' p2 /* slash found,extract what's before it */
foo=translate(p1,' ','.')
if words(foo)>1 then do /* >0 periods signifies this is an ip address */
anip=p1
aport=80
afile=p2
end
else do
anip=servername
aport=serverport
afile=message
end
end
isit="http://"||anip
if aport<>80 then
isit=isit||':'||aport
isit=isit||'/'||afile
return isit